# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: AndyRTR <andyrtr@archlinux.org>

pkgname=hunspell-hu
pkgver=1.8
pkgrel=2
pkgdesc='Hungarian hunspell dictionary'
arch=('any')
url='https://magyarispell.sourceforge.net/'
license=('LGPL' 'GPL' 'MPL')
makedepends=('git' 'qt6-webengine')
optdepends=('hunspell: the spell checking libraries and apps')
provides=('hunspell-dictionary')
_commit=2404521a6c320ae5e307c6c0fed31d81de751a88
source=("git+https://git.libreoffice.org/dictionaries#commit=$_commit")
sha256sums=('SKIP')

package() {
  cd dictionaries/hu_HU/
  install -dm755 "$pkgdir"/usr/share/{hunspell,qt{,6}/qtwebengine_dictionaries}
  install -m644 -t "$pkgdir/usr/share/hunspell" hu_HU.dic hu_HU.aff

  # Install webengine dictionary; the IGNORE command is not supported by bdic
  sed -i '/^IGNORE/d' hu_HU.aff
  /usr/lib/qt6/qwebengine_convert_dict hu_HU.dic "$pkgdir/usr/share/qt6/qtwebengine_dictionaries/hu_HU.bdic"
  ln -rs "$pkgdir"/usr/share/qt6/qtwebengine_dictionaries/hu_HU.bdic "$pkgdir"/usr/share/qt/qtwebengine_dictionaries/

  # the symlinks
  install -dm755 "$pkgdir/usr/share/myspell/dicts"
  pushd "$pkgdir/usr/share/myspell/dicts"
    for file in "$pkgdir"/usr/share/hunspell/*; do
      ln -sv /usr/share/hunspell/$(basename $file) .
    done
  popd

  # docs
  install -Dm644 README_hu_HU.txt "$pkgdir/usr/share/doc/$pkgname/README_hu_HU.txt"
}
